public class lengthOfLIS {
    public int lengthOfLIS(int[] nums) {
        int len = nums.length;
        int ans = 0;
        int[] dp = new int[len + 1];
        for(int i = 1;i <= len;i++) {
            dp[i] = 1;
            for(int j = i - 1;j >= 1;j--) {
                if(nums[i - 1] > nums[j - 1]) {
                    dp[i] = Math.max(dp[i],dp[j] + 1);
                }
            }
            ans = Math.max(ans,dp[i]);
        }

        return ans;
    }
}
